home *** CD-ROM | disk | FTP | other *** search
/ PC Graphics Unleashed / PC Graphics Unleashed.iso / ch17 / pi / space / space.pi < prev    next >
Encoding:
Text File  |  1994-08-04  |  3.5 KB  |  164 lines

  1. // Scene File: SPACE.PI
  2. // Author: Rob McGregor
  3.  
  4. // Planets, space station, and alien ship 
  5.  
  6. // Define the range of the animation
  7. start_frame  0
  8. end_frame    299
  9. total_frames 300
  10. outfile "space"
  11.  
  12. // Calculate the values of all transformations
  13. static define xShipStart 4
  14. static define zShipStart -100
  15.  
  16. define xShipPos xShipStart + (0.05 * (frame + zShipStart))
  17. define zShipPos zShipStart + (1.35 * (frame + zShipStart))
  18. define zRot     9 * frame
  19. define zPos     -200 + frame
  20.  
  21. // Lights
  22. light <-5, 2, -15>
  23. light <5, 2, -15>
  24.  
  25. // Set up the camera
  26. viewpoint {
  27.   from       <5, 2, zPos>
  28.   at         <0, 0, 0>
  29.   up         <0, 1, 0>
  30.   angle      45
  31.   resolution 320, 200
  32.   aspect     1.6
  33. }
  34.  
  35. // Create some nice metallic textures
  36. static define ring_color <0.70, 0.56, 0.37>
  37. static define hull_color <0.55, 0.5, 0.45>
  38.  
  39. // The hull of the space station (light side)
  40. static define light_hull
  41. texture {
  42.   surface {
  43.     color hull_color
  44.     specular hull_color, 0.85
  45.     ambient 0.20
  46.     diffuse 0.35
  47.     microfacet Cook 12
  48.     reflection 0.45
  49.   }
  50. }
  51.  
  52. // The hull of the space station (dark side)
  53. static define dark_hull
  54. texture {
  55.   surface {
  56.     color hull_color
  57.     specular hull_color, 0.85
  58.     ambient 0.75
  59.     diffuse 0.35
  60.     microfacet Cook 12
  61.     reflection 0.45
  62.   }
  63. }
  64.  
  65. static define ring_color 
  66. texture {
  67.   surface {
  68.     color ring_color
  69.     specular ring_color, 0.65
  70.     ambient 0.1
  71.     diffuse 0.45
  72.     microfacet Cook 12
  73.     reflection 0.45
  74.   }
  75. }
  76.  
  77. static define shipTex 
  78. texture {
  79.   special surface {
  80.     color spherical_imagemap(image ("shiptex.tga"), P)
  81.     specular white, 0.65
  82.     ambient 0.9
  83.     microfacet Phong 7
  84.     //reflection 0.45
  85.   }
  86. }
  87.  
  88. // Map one of two cool space scenes to the background
  89. if (zPos <= 0) 
  90.   // Toward the station, planets visible...
  91.   background planar_imagemap(image("planets.tga"), P)
  92. else 
  93.   // Away from the station, on the dark side...
  94.   background planar_imagemap(image("stars.tga"), P)
  95.  
  96. // Build a simple space station
  97. // Main Hull
  98. static define hull
  99. object {
  100.   cylinder <0.0, -1.0, 0.0>, <0.0, 1.0, 0.0>, 0.25
  101. }
  102.  
  103. // Create a ring structure from 11 tori.
  104. static define ring
  105. object { torus 0.5, 0.015, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0> }
  106.  
  107. static define rings
  108. object{
  109.   object { ring } 
  110.   + 
  111.   object { ring translate <0.0, 0.4, 0.0> }
  112.   +
  113.   object { ring translate <0.0, 0.8, 0.0> } 
  114.   +
  115.   object { ring translate <0.0, -0.4, 0.0> }
  116.   +
  117.   object { ring translate <0.0, -0.8, 0.0> }
  118.   +
  119.   object { ring translate <0.0, 0.6, 0.0> }
  120.   +
  121.   object { ring translate <0.0, 0.2, 0.0> }
  122.   +
  123.   object { ring translate <0.0, -0.2, 0.0> }
  124.   +
  125.   object { ring translate <0.0, -0.6, 0.0> }
  126.   +
  127.   object { ring translate <0.0, 1.0, 0.0> }
  128.   +
  129.   object { ring translate <0.0, -1.0, 0.0> }
  130. }
  131.  
  132. // CSG space station object
  133. if (zPos <= 0){    // this is the light side
  134.   define station
  135.   object {
  136.     object { hull light_hull scale <10,10,10> }
  137.     +
  138.     object { rings ring_color scale <10,10,10> }
  139.   }
  140. }
  141. else {             // this is the dark side, ambience enhanced
  142.   define station
  143.   object {
  144.     object { hull dark_hull scale <10,10,10> }
  145.     +
  146.     object { rings ring_color scale <10,10,10> }
  147.   }
  148. }
  149.  
  150. // Rotate the station
  151. object { station rotate <0, 0, zRot> }
  152.  
  153. // Bring in another actor, a spaceship
  154. if (zPos > -99)
  155.   object { 
  156.     sphere <0, 0, 0>, 1
  157.     scale <1, 1, 10> 
  158.     rotate <0, 10, 0>
  159.     translate <xShipPos, 1.5, zShipPos>
  160.     shipTex
  161.   }
  162.    
  163. // End of File
  164.